<template>
  <div>
    <div class="topheader">
      <div class="img">
        <img :src="playlisty.Image" alt="" />
      </div>

      <div class="title">{{ playlisty.Info }}</div>
      <!-- 图标 -->
      <div
        class="button"
        @click="$router.push('/index/recommend'), getNavsBtnFun()"
      >
        <span class="iconfont icon-fanhuipt"></span>
        {{ playlist.tags[0] || "排行榜" }}
      </div>
    </div>

    <dl class="musicList">
      <dt>
        <i class="iconfont icon-zanting-wangyiicon" @click="setFristId"></i
        >全部播放&nbsp;<span>共20首</span>
      </dt>
      <dd@click="setId(playlisty.Mid1)">
        <h1>1</h1>
        <div class="info">
          <h2>{{ playlisty.MName1 }}</h2>
          <h3>{{ playlisty.MSName1 }}</h3>
        </div>
      </dd>
	  <dd@click="setId(playlisty.Mid2)">
	    <h1>2</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName2 }}</h2>
	      <h3>{{ playlisty.MSName2 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid3)">
	    <h1>3</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName3 }}</h2>
	      <h3>{{ playlisty.MSName3 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid4)">
	    <h1>4</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName4 }}</h2>
	      <h3>{{ playlisty.MSName4 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid5)">
	    <h1>5</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName5 }}</h2>
	      <h3>{{ playlisty.MSName5 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid6)">
	    <h1>6</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName6 }}</h2>
	      <h3>{{ playlisty.MSName6 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid7)">
	    <h1>7</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName7 }}</h2>
	      <h3>{{ playlisty.MSName7 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid8)">
	    <h1>8</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName8 }}</h2>
	      <h3>{{ playlisty.MSName8 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid9)">
	    <h1>9</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName9 }}</h2>
	      <h3>{{ playlisty.MSName9 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid10)">
	    <h1>10</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName10 }}</h2>
	      <h3>{{ playlisty.MSName10 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid11)">
	    <h1>11</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName11 }}</h2>
	      <h3>{{ playlisty.MSName11 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid12)">
	    <h1>12</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName12 }}</h2>
	      <h3>{{ playlisty.MSName12 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid13)">
	    <h1>13</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName13 }}</h2>
	      <h3>{{ playlisty.MSName13 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid14)">
	    <h1>14</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName14 }}</h2>
	      <h3>{{ playlisty.MSName14 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid15)">
	    <h1>15</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName15 }}</h2>
	      <h3>{{ playlisty.MSName15 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid16)">
	    <h1>16</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName16 }}</h2>
	      <h3>{{ playlisty.MSName16 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid17)">
	    <h1>17</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName17 }}</h2>
	      <h3>{{ playlisty.MSName17}}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid18)">
	    <h1>18</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName18 }}</h2>
	      <h3>{{ playlisty.MSName18 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid19)">
	    <h1>19</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName19 }}</h2>
	      <h3>{{ playlisty.MSName19 }}</h3>
	    </div>
	  </dd>
	  <dd@click="setId(playlisty.Mid20)">
	    <h1>20</h1>
	    <div class="info">
	      <h2>{{ playlisty.MName20 }}</h2>
	      <h3>{{ playlisty.MSName20 }}</h3>
	    </div>
	  </dd>
    </dl>
  </div>
</template>

<script>
import { getPlaylistDetail } from "../../api/ranking";
export default {
  data() {
    return {
      playlist: {
        coverImgUrl: "",
        tags: [""],
        tracks: [],
      },
	  playlisty:null
    };
  },
  created() {
    let queryId = this.$route.query;
    if (!("id" in queryId)) {
      this.$router.push("/index/recommend");
    }
    getPlaylistDetail({ id: queryId.id }).then((data) => {
      console.log(data);
      this.playlisty = data.data;
	  console.log(this.playlisty);
    });
    this.$emit("getnavs-btn", false); 
    this.$emit("get-style", true);

  },
  methods: {
    setFristId() {
      this.$emit("get-player-id", this.playlist.tracks[0].id);
    },
    setId(id) {
      // 播放全部歌曲
      this.$emit("get-play-all-id", this.$route.query.id); //传递歌单id
      this.$emit("get-player-id", id);
    },
    getNavsBtnFun() {
      this.$emit("getnavs-btn", true);
      this.$emit("get-style", false);

    },
  },
};
</script>

<style lang="less">
.topheader {
  height: 270px;
  position: relative;
  .img {
    background-color: pink;
    width: 100%;
    height: 270px;
    position: relative;
    img {
      position: absolute;
      top: 0;
      right: 0;
      left: 0;
      bottom: 0;
      margin: auto;
      width: 100%;
    }
  }
  .title {
    font-size: 18px;
    position: absolute;
    left: 18px;
    bottom: 18px;
    color: #fff;
  }
  .button {
    font-size: 18px;
    position: absolute;
    left: 12px;
    top: 12px;
    color: #fff;
  }
}

.musicList {
  background-color: #fff;
  width: 100%;
  border-radius: 7px;
  position: relative;
  top: -7px;
  padding-bottom: 100px;
  dt {
    height: 36px;
    line-height: 36px;
    font-size: 16px;
    color: #454747;
    border-bottom: 1px solid #e3e3e3;
    span {
      font-size: 14px;
      color: #797b7a;
    }
    i {
      font-size: 25px;
      width: 44px;
      text-align: center;
      display: inline-block;
    }
  }

  dd {
    border-bottom: 1px solid #e3e3e3;
    height: 53px;
    display: flex;
    h1 {
      flex: 0 0 44px;
      line-height: 53px;
      text-align: center;
      font-size: 16px;
      color: #6d6e6e;
    }
    .info {
      flex: 1;
      h2 {
        font-size: 16px;
        color: #1b1c1c;
        margin-top: 10px;
        // 1、固定宽度（高度可有可无）：width: 195px;
        // 2、把盒子转成弹性伸缩盒子：
        display: -webkit-box;
        // 3、弹性盒子排列方式：垂直排列：
        -webkit-box-orient: vertical;
        // 4、规定显示几行文本：
        -webkit-line-clamp: 1;
        // 5、溢出隐藏：
        overflow: hidden;
      }
      h3 {
        font-size: 12px;
        color: #929393;

        display: -webkit-box;
        // 3、弹性盒子排列方式：垂直排列：
        -webkit-box-orient: vertical;
        // 4、规定显示几行文本：
        -webkit-line-clamp: 1;
        // 5、溢出隐藏：
        overflow: hidden;
      }
    }
  }
}
</style>